// Tags: Prefix, Possibility
#include <algorithm>
#include <cstdio>
#define int ll
typedef long long ll;

const int N = 1e6 + 5;
int n, m, qwq, maxdep, a[N], prefix[N], val[N << 2];

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

void dfs(int l, int r, int d) {
  if (l == r) { return maxdep = std::max(maxdep, d), void(); }
  int mid = (l + r) >> 1;
  dfs(l, mid, d + 1);
  dfs(mid + 1, r, d + 1);
}

void build(int x, int l, int r, int d) {
  val[x] = 1 << (maxdep - d);
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(x << 1, l, mid, d + 1);
  build(x << 1 | 1, mid + 1, r, d + 1);
}

void pre(int x, int l, int r, ll v) {
  if (l == r) { return prefix[l] = v, void(); }
  int mid = (l + r) >> 1;
  pre(x << 1, l, mid, v + val[x << 1]);
  pre(x << 1 | 1, mid + 1, r, v + val[x << 1 | 1]);
}

signed main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("P3924 康娜的线段树.in", "r", stdin);
  freopen("P3924 康娜的线段树.out", "w", stdout);
#endif
#endif

  scanf("%lld%lld%lld", &n, &m, &qwq);
  for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
  ll ans = 0;
  dfs(1, n, 0);
  build(1, 1, n, 0);
  pre(1, 1, n, val[1]);
  int mgcd = gcd(1 << maxdep, qwq);
  for (int i = 1; i <= n; ++i) {
    ans += prefix[i] * a[i];
    prefix[i] += prefix[i - 1];
  }
  for (int i = 1, l, r, x; i <= m; ++i) {
    scanf("%lld%lld%lld", &l, &r, &x);
    ans += x * (prefix[r] - prefix[l - 1]);
    // printf("%lld\n", qwq * ans / (1 << maxdep));
    printf("%lld\n", 1ll * qwq / mgcd * ans / ((1 << maxdep) / mgcd));
  }
  return 0;
}